<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Models\Candy\Tech;

class CreateCandyTechTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = "CREATE TABLE `".Tech::getFullTableTable()."` (
  `".Tech::DB_FIELD_ID."` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `".Tech::DB_FIELD_DATE."` date NOT NULL COMMENT '日期',
  `".Tech::DB_FIELD_TITLE."` varchar(255) DEFAULT '' COMMENT '文本',
  `".Tech::DB_FIELD_TEXT."` varchar(2000) DEFAULT NULL COMMENT '内容',
  `".Tech::DB_FIELD_MEDIA_TYPE."` tinyint(4) unsigned DEFAULT '1' COMMENT '媒体类型1文本2横版图片3竖版图片4横版视频5竖版视频6时间',
  `".Tech::DB_FIELD_MEDIA_SOURCE."` tinyint(4) unsigned DEFAULT '1' COMMENT '来源1腾讯云2url',
  `".Tech::DB_FIELD_MEDIA_CONTENT."` varchar(1000) DEFAULT NULL COMMENT '媒体内容',
  `".Tech::DB_FIELD_IS_PRIVATE."` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '私密图片0不是1是',
  `".Tech::DB_FIELD_CREATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `".Tech::DB_FIELD_UPDATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `".Tech::DB_FIELD_DELETED_AT."` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `idx_date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
        DB::connection()->getPdo()->exec($sql);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop(Tech::getFullTableTable());
    }
}
